package foo.bar.wiki.web.extension;

import foo.bar.wiki.domain.Resource;
import foo.bar.wiki.services.WikiService;
import net.sourceforge.stripes.validation.ValidationError;
import net.sourceforge.stripes.integration.spring.SpringBean;

import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: 1269870
 * Date: Apr 30, 2009
 * Time: 12:09:51 PM
 * To change this template use File | Settings | File Templates.
 */
public class ResourceTypeConverter extends AbstractIdentifiableTypeConverter<Resource> {

    private WikiService wikiService;

    protected Resource _convert(String id, Class<? extends Resource> targetType,
                                Collection<ValidationError> errors) {
        return wikiService.getResourceById(id);
    }


    @SpringBean("wikiService")
    public void setWikiService(WikiService wikiService) {
        this.wikiService = wikiService;
    }


}
